<?php

namespace Biz\model\bizAd;

use Biz\pockets\modelTrait\BizModelTrait;
use Doraemon\pockets\datebase\BaseDbModel;
use Doraemon\tools\HhzEnv;

class AdPrice extends BaseDbModel
{
    const _CONFIG_FILE_ = 'db_biz_ad';

    const _CONFIG_SELECT_ = 'db_biz_ad';

    const _DATABASE_ = 'biz_ad';

    const _TABLE_NAME = 'hhz_ad_price';

    use BizModelTrait;

    const PRICE_STATUS_NORMAL = 0;
    const PRICE_STATUS_DELETE = 9;


    public static function getAllPrice($fields = [])
    {
        $fields['price_status'] = self::PRICE_STATUS_NORMAL;
        return self::dataSelect($fields);
    }

    public static function getUserPackage()
    {
        $packageIds = self::dataPluck(['price_status' => self::PRICE_STATUS_NORMAL], 'package');
        return array_unique($packageIds);
    }

    public static function getInfoById($id)
    {
        return self::dataSelectInfo(['id' => $id]);
    }

    public static function hasPackageInfo($package, $count)
    {
        return self::dataSelectInfo(['package' => $package, 'count' => $count, 'price_status' => self::PRICE_STATUS_NORMAL]);
    }

    public static function getUserPackageMap()
    {
        $userPackageMap = [];
        if (HhzEnv::isShopTest()) {//hhzdev
            $userPackageMap = [
                0 => '智能推荐',
                11 => '家具标准包',
                12 => '家具精准包',
                13 => '建材标准包',
                14 => '建材精准包'
            ];
        } else if (HhzEnv::isTest()) {//haohaoce
            $userPackageMap = [
                0 => '智能推荐',
                1 => '家具标准包',
                2 => '家具精准包',
                3 => '建材标准包',
                4 => '建材精准包'
            ];
        } else if (HhzEnv::isProduction()) {//online
            $userPackageMap = [
                0 => '智能推荐',
                72 => '家具标准包',
                73 => '家具精准包',
                74 => '建材标准包',
                75 => '建材精准包',
                128 => '家电标准包',
                127 => '家电精准包',
            ];
        }
        return $userPackageMap;
    }
}